package com.lxk.service.impl;

import com.lxk.dao.AsMyMapper;
import com.lxk.dao.OnsaleMapper;
import com.lxk.pojo.Onsale;
import com.lxk.pojo.OnsaleExample;
import com.lxk.service.OnsaleService;
import com.lxk.vo.OnsaleShowModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author JohnSoybean
 * @create 2020/4/2 14:10
 * @description
 */
@Service
@Transactional
public class OnsaleServiceImpl implements OnsaleService {

    @Autowired
    private OnsaleMapper om;
    @Autowired
    private AsMyMapper mm;

    public List<Onsale> selOnsaleByGoodsId(Integer goodsId) {
        OnsaleExample example = new OnsaleExample();
        OnsaleExample.Criteria criteria = example.createCriteria();
        criteria.andGoodsIdEqualTo(goodsId);
        List<Onsale> onsaleList = om.selectByExample(example);
        return onsaleList;
    }

    public void deleteOnsale(Integer onsaleId) {
        om.deleteByPrimaryKey(onsaleId);
    }

    public void addOnsale(Onsale onsale) {
        om.insertSelective(onsale);
    }


    public List<OnsaleShowModel> showOnsaleGoodsList() {
        List<OnsaleShowModel> list = mm.selOnsaleShowModel();
        return list;
    }

}
